home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SNIP0492.ARJ / ANSILOAD.C < prev    next >
C/C++ Source or Header  |  1991-09-21  |  1KB  |  59 lines

  1. /*
  2. **  ANSILOAD.C - tries to detect if an ANSI-style driver is loaded
  3. **
  4. **  public domain by Bob Jarvis
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <dos.h>
  9.  
  10. void goto_rc(int row, int col)
  11. {
  12.       union REGS regs;
  13.  
  14.       regs.h.ah = 2;
  15.       regs.h.bh = 0;                /* assumes we're using video page 0 */
  16.       regs.h.dh = (unsigned char)row;
  17.       regs.h.dl = (unsigned char)col;
  18.  
  19.       int86(0x10, ®s, ®s);
  20. }
  21.  
  22. void get_rc(int *row, int *col)
  23. {
  24.       union REGS regs;
  25.  
  26.       regs.h.ah = 3;
  27.       regs.h.bh = 0;                /* again, assume video page 0       */
  28.  
  29.       int86(0x10, ®s, ®s);
  30.  
  31.       *row = regs.h.dh;
  32.       *col = regs.h.dl;
  33. }
  34.  
  35. int is_ansi_loaded(void)
  36. {
  37.       int save_r, save_c;
  38.       int new_r, new_c;
  39.  
  40.       get_rc(&save_r, &save_c);
  41.       goto_rc(15,15);
  42.       printf("\x1B[0;0H");
  43.  
  44.       get_rc(&new_r, &new_c);
  45.  
  46.       goto_rc(save_r, save_c);
  47.  
  48.       if(new_r == 0 && new_c == 0)
  49.             return -1;
  50.       else  return 0;
  51. }
  52.  
  53. void main(void)
  54. {
  55.       if(is_ansi_loaded())
  56.             puts("ANSI.SYS is loaded");
  57.       else  puts("ANSI.SYS is NOT loaded");
  58. }
  59.